<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache,no-store,must-revalidate">
    <meta http-equiv="Cache" content="no-cache">
		<title>新增页面</title>
		<link rel="stylesheet" href="../../../component/pear/css/pear.css" />
	</head>
	<body>
		<form class="layui-form" action="">
			<div class="mainBox">
				<div class="main-container">

					<div class="layui-form-item">
						<label class="layui-form-label">二维码名称</label>
						<div class="layui-input-block">
							<input type="text" name="qrTypeName" lay-verify="required" autocomplete="off" placeholder="请输入二维码名称"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">型名开始位</label>
						<div class="layui-input-block">
							<input type="number" name="pnFrom" lay-verify="number" autocomplete="off" placeholder="请输入型名开始位"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">型名长度</label>
						<div class="layui-input-block">
							<input type="number" name="pnLength" lay-verify="number" autocomplete="off" placeholder="请输入型名长度"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">LotNo开始位</label>
						<div class="layui-input-block">
							<input type="number" name="lotNoFrom" lay-verify="number" autocomplete="off" placeholder="请输入LotNo开始位"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">LotNo长度</label>
						<div class="layui-input-block">
							<input type="number" name="lotNoLength" lay-verify="number" autocomplete="off" placeholder="请输入LotNo长度"
								class="layui-input">
						</div>
					</div>

				</div>
			</div>
			<div class="bottom">
				<div class="button-container">
					<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
						lay-filter="qrTypeAdd">
						<i class="layui-icon layui-icon-ok"></i>
						提交
					</button>
					<button type="reset" class="pear-btn pear-btn-sm">
						<i class="layui-icon layui-icon-refresh"></i>
						重置
					</button>
				</div>
			</div>
		</form>
		<script src="../../../component/layui/layui.js"></script>
		<script src="../../../component/pear/pear.js"></script>


		
		<script type="text/javascript">
			// 加载自定义模块,检查浏览器和token
			layui.extend({
        myheader: "{/}/lay-ext/myheader",
      });
			
			layui.use(['form', 'jquery','myheader','layer','laytpl'], function() {
				let form = layui.form;
				let $ = layui.jquery;
				let myheader = layui.myheader;
				let layer = layui.layer;
				let laytpl = layui.laytpl;

				// 定义全局 ajax的请求头
				myheader.ajaxGlobal(myheader.checkToken().tokenValue);

				// form 确认上传
				form.on('submit(qrTypeAdd)', function(data) {
					$.ajax({
						url: parent.layui.myheader.baseUrl()+ '/qrType/addQrType',
						data: JSON.stringify({
							qrTypeName:data.field.qrTypeName,
							pnFrom:data.field.pnFrom,
							pnLength: data.field.pnLength,
							lotNoFrom: data.field.lotNoFrom,
							lotNoLength: data.field.lotNoLength
						}),
						contentType: 'application/json',		// 请求时的数据类型
						type: 'post',
						success: function(data) {
							if (data.data==1) {
								layer.msg("已添加", {
									time: 1000
								}, function() {
									parent.layer.close(parent.layer.getFrameIndex(window
										.name)); //关闭当前页
									parent.layui.table.reloadData('qrtype-table',{
										scrollPos: 'fixed'  // 保持滚动条位置不变 - v2.7.3 新增
									});
								});
							} else {
								layer.msg("添加失败", {
									time: 1000
								});
							}
						}
					})
					return false;
				});

			})
		</script>

	</body>
</html>
